@include('admin.head')
<div class="container">
	<div class="row">
		@include('admin.side')
		<div class="col-md-10" id="content-wrapper">
			<div id="myTabContent" class="tab-content">
			 	<div class="tab-pane fade active in" id="home">
					<div class="row">
						<div class="col-xs-12">
							<div class=" clearfix">
								<div class="clearfix">
									<h2 class="pull-left" id="pageTitle"></h2>
								</div>
								<div class="panel panel-default" id="base">
									<div class="panel-body">
										<div class="form-horizontal">
										  <fieldset>


										    <div class="form-group">
										      <label class="col-xs-2 control-label no_padding_right">页面名称:</label>
										      <div class="col-xs-4">
										        <input class="form-control input_size" name="name"  placeholder="" type="text">
										      </div>
										    </div>

										    <div class="form-group">
										      <label class="col-xs-2 control-label no_padding_right">唯一标识:</label>
										      <div class="col-xs-4">
										        <input class="form-control input_size" name="unique_key"  placeholder="" type="text" readonly="readonly">
										      </div>
										    </div>

											<div class="form-group">
										      <label class="col-xs-2 control-label no_padding_right">页面内容:</label>
										      <div class="col-xs-8" id="pageContent" style="height:400px;"></div>
										    </div>

										    <div class="form-group">
										      <div class="col-xs-12 text-center">
										      	<input type="hidden" name="did">
										        <button type="button" id="pro_sub" class="btn btn-primary ">提交</button>
										      </div>
										    </div>

										  </fieldset>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
			  	</div>
			</div>
		</div>
	</div>
</div>
@include("admin.footer")
@include("admin.common")
</body>




<script type="text/javascript">
var url = "<%url('admin')%>/";

var ue = UE.getEditor('pageContent');

var pid = "<%Input::get('pid')%>";
$.get(url + 'page/get_page',{pid:pid},function(data){
	if(data.success){
		$("input[name='name']").val(data.data.page_name);
		$("#pageTitle").text(data.data.page_name);
		$("input[name='unique_key']").val(data.data.unique_key);
		if(data.data.page_content){
			ue.ready(function(){
			    ue.setContent(decodeURIComponent(data.data.page_content));
			});
		}
	}
})

$("#pro_sub").click(function(){
	var name = $("input[name = 'name']").val().trim();
	if( name == '' )
	{
		warning("", "页面名称不能为空!");
		return false;
	}

	$.post(url + "page/update_page",{
		pid: pid,
		page_name : name,
		page_content: encodeURIComponent(ue.getContent())
	},function (data){
		if(data.success){
			success("","提交成功");
			setTimeout(function(){
				window.location.href="../page";
			},1000);
		}else{
			error("" ,data.msg);
		}
	})
})

</script>

</html>